package com.thrd.taiexhibition.ui;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.thrd.taiexhibition.R;
import com.thrd.taiexhibition.bean.BeanCityIndustry;
import com.thrd.taiexhibition.utils.ImageCachceUitl;

/**
 * @author: ${唐杰}
 * @date: 2021/4/16
 */
public class TouchRelativeLayout extends RelativeLayout {
    public TouchRelativeLayout(Context context) {
        super(context);
    }

    public TouchRelativeLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public TouchRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    private BeanCityIndustry mBeanCityIndustry;

    public  void setTouchData(final BeanCityIndustry mBeanCityIndustry){
        this.mBeanCityIndustry=mBeanCityIndustry;
//        setImagePath(this, Constant.IMAGE+mBeanCityIndustry.getIndustryLocationImg());
    }

    private void setImagePath(TouchRelativeLayout touchRelativeLayout, String url) {
        ImageCachceUitl.getInstance().getBitmapFromFile(url, new ImageCachceUitl.OnBitmapCallback() {
            @Override
            public void onBitmapCallback(Bitmap response) {
                ImageView imageView=new ImageView(getContext());
                imageView.setImageBitmap(response);
                touchRelativeLayout.addView(imageView, LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
               // setView();
            }

            @Override
            public void onBitmapError(String e) {

            }
        });






    }

//    private void setView(){
//        List<BeanCityIndustryCoordinate> mBeanCityIndustryCoordinateList= mBeanCityIndustry.getCityIndustryList();
//        if(mBeanCityIndustryCoordinateList!=null){
//            for(BeanCityIndustryCoordinate mBeanCityIndustryCoordinate:mBeanCityIndustryCoordinateList){
//                RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(mBeanCityIndustryCoordinate.getWidth(),mBeanCityIndustryCoordinate.getLength());
//                lp.leftMargin=mBeanCityIndustryCoordinate.getxAxis();
//                lp.topMargin=mBeanCityIndustryCoordinate.getyAxis();
//                View mImageView=new View(getContext());
//                mImageView.setBackgroundColor(Color.BLACK);
//                addView(mImageView,lp);//RelativeLayout添加子View
//              //  startAnimention(mImageView);
//            }
//
//        }
//    }


    private void startAnimention(View view){
        Animation translateAnimation2= AnimationUtils.loadAnimation(getContext(), R.anim.industry_1);//加载Xml文件中的动画
        translateAnimation2.setDuration(1000);
        translateAnimation2.setRepeatCount(1000);
        translateAnimation2.setRepeatMode(Animation.REVERSE);
        view.startAnimation(translateAnimation2);
    }
}
